<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

<div class="layui-fluid">
     <div class="layui-card">
      <div class="layuiadmin-card-header-auto">
        <div class="layui-text-item" style="text-align: center;"><b><!--{$lang.page.public.share}--></b></div>
        <div class="layui-text-item" style="padding-bottom:20px">
          <div class="layui-text-line">
            <label class="layui-text-label"><!--{$lang.page.public.sharelink}--></label>
            <div class="layui-text-inline">
              <!--{$user.share}-->     
            </div>
            <div class="layui-text-inline">
              <button type="button" class="layui-btn layui-btn-sm" id="copycode" data-set="<!--{$user.share}-->"><!--{$lang.page.public.copy}--></button>    
            </div>
          </div>
        </div>
        <div class="layui-text-item" style="height: 120px;">
          <div class="layui-text-line">
            <label class="layui-text-label"><!--{$lang.page.public.qcode}--></label>
            <div class="layui-text-inline">
               <img src="<!--{$user.ewmurl}-->" width="80px" style="cursor: pointer;" onclick="xadmin.showimg({url:'<!--{$user.ewmurl}-->',title:'<!--{$lang.page.public.qcode}-->',w:580,h:580})">   
            </div>
          </div>
          <div class="layui-text-line">
            <a type="button" class="layui-btn layui-btn-sm" target="blank" download='share' href="<!--{$user.baseurl}--><!--{$user.ewmurl}-->" ><!--{$lang.page.table.download}--></a> 
          </div>
          <div class="layui-text-line">
            <button type="button" class="layui-btn layui-btn-sm" id="ewm"><!--{$lang.page.public.generate}--> <!--{$lang.page.public.qcode}--></button>
          </div>
        </div>
        <div class="layui-text-item" style="height: 120px; ">
          <div class="layui-text-line">
            <label class="layui-text-label"><!--{$lang.page.public.backimg}--></label>
            <div class="layui-text-inline">
                <li style="width: 100px" id="picdemo" <!--{if empty($user.backurl)}-->style="display:none;"<!--{/if}-->>
                <img id="demo" style="width: 100%;cursor: pointer" src="<!--{$user.backurl}-->" onclick="xadmin.showimg({url:'<!--{$user.backurl}-->',title:'<!--{$lang.page.public.backimg}-->',w:300,h:580})"/></li>  
            </div>
          </div>
          <div class="layui-text-line">
            <label class="layui-text-label"><!--{$lang.page.public.promimg}--></label>
            <div class="layui-text-inline">
               <img src="<!--{$user.shareurl}-->" width="260px" style="cursor: pointer;" onclick="xadmin.showimg({url:'<!--{$user.shareurl}-->',title:'<!--{$lang.page.public.promimg}-->',w:360,h:680})">   
            </div>
          </div>
          <div class="layui-text-line">
            <a class="layui-btn layui-btn-sm" target="blank" download='share' href="<!--{$user.baseurl}--><!--{$user.shareurl}-->" ><!--{$lang.page.table.download}--></a> 
            <a class="layui-btn layui-btn-sm" id="backgound"><!--{$lang.page.public.upimg}--></a>
            <a class="layui-btn layui-btn-sm" id="share"><!--{$lang.page.public.generate}--></a>
          </div>
        </div>
      </div>
     </div>
 </div>
<script src="/static/lay/layui/layui.js"></script>
  <script type="text/javascript">
    layui.config({
     base: '/static/lay/' //静态资源所在路径
   }).extend({
     xadmin: 'lib/xadmin' //弹窗
   }).use(['jquery', 'layer','xadmin', 'form','upload'], function(){
    var form = layui.form
        ,$ = layui.jquery
        ,upload = layui.upload;
     form.render(null, 'component-form-group');
     /* 自定义验证规则 */
    form.verify({

      username: function(value){
        if(value.length < 1){
          return '<!--{$lang.page.table.account}--> <!--{$lang.page.public.nocontent}-->';
        }
      }

    });

    form.on('submit(submit)', function (data) {
        $('#submit').attr("disabled",true);
        $('#submit').addClass('layui-btn-disabled');
        $.post('#',data.field,function(res){
            if(res.code == 200){
                xadmin.close();
                layer.msg(res.msg);
            }else{
                layer.msg(res.msg);
            }
        })
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });
    //重置按钮，可以提交失败的时候再次提交
    $('#reset').click(function(){
        $('#submit').removeAttr("disabled");
        $('#submit').removeClass('layui-btn-disabled');
    });

    $('#ewm').click(function(){
        $.post('#',{sc:1,aid:<!--{$user.aid}-->},function(res){
                if(res.code == 200){
                  layer.msg(res.msg);
                  setTimeout(() => {
                    window.location.reload();
                  }, 1000); 
                }else{
                  layer.msg(res.msg);
                }
              })
    });

    $('#share').click(function(){
        $.post('#',{sc:2,aid:<!--{$user.aid}-->},function(res){
                if(res.code == 200){
                  layer.msg(res.msg);
                  setTimeout(() => {
                    window.location.reload();
                  }, 1000); 
                }else{
                  layer.msg(res.msg);
                }
              })
    });

    var uploadInst = upload.render({
      elem: '#backgound'
      ,url: '/user/common/uploadimg/?folder=qrcode&name='+<!--{$user.aid}-->
      ,done: function(res){
      //上传成功
        if (res.code == 200) {
            if(res.data.src){
              $.post('#',{aid:<!--{$user.aid}-->,backurl:res.data.src},function(res){
                if(res.code == 200){
                  layer.msg(res.msg);
                  setTimeout(() => {
                    window.location.reload();
                  }, 1000); 
                }else{
                  layer.msg(res.msg);
                }
              })
            }
          } else {
            layer.msg(res.msg);
          }
        }
    });

    $('#copycode').on('click', function(e){
        var data = e.target.dataset.set;
        var oInput = document.createElement('input');
        oInput.value = data;
        document.body.appendChild(oInput);
        oInput.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        oInput.className = 'oInput';//设置class名
        document.getElementsByClassName("oInput")[0].remove();//移除这个input
        layer.msg('<!--{$lang.page.public.copysuc}-->', { icon: 0, skin: 'success_msg', time: 3000 });// success_msg; error_msg;warn_msg; 
    })

  });
  </script>
</body>
</html>

